package com.swak.disruptor;

import java.util.Arrays;
import java.util.concurrent.Executors;

import com.lmax.disruptor.SleepingWaitStrategy;
import com.lmax.disruptor.dsl.Disruptor;
import com.lmax.disruptor.dsl.ProducerType;

public class DisruptorDemo {

	public static void main(String[] args) {
		Disruptor<MsgEvent> disruptor = new Disruptor<>(MsgEvent::new, 1024, Executors.defaultThreadFactory(),
				ProducerType.MULTI, new SleepingWaitStrategy());

		// 定义消费者
		MsgConsumer msg1 = new MsgConsumer("1");

		// 绑定配置关系
		disruptor.handleEventsWith(msg1);
		disruptor.start();

		// 定义要发送的数据
		MsgProducer msgProducer = new MsgProducer(disruptor);
		msgProducer.send(Arrays.asList("nihao", "hah"));
	}
}
